accessible: Avoid realizing the context prematurely
authorMatthias Clasen <mclasen@redhat.com>
Wed, 14 Oct 2020 04:16:23 +0000 (00:16 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 15 Oct 2020 01:04:25 +0000 (21:04 -0400)
platform change is called from gtk_widget_set_focusable
which is likely to be called early on in init(). We don't
want to create an AT context that early if we can help
it, e.g. since it makes it impossible to override the
accessible-role with a construct property.

gtk/gtkaccessible.c

index 1f3e2a3209d0fd2ecc539516c6376041c74dc74f..582cdf08fd841e8f20071c660f3abca4086d0a94 100644 (file)
@@ -656,14 +656,17 @@ void
 gtk_accessible_platform_changed (GtkAccessible               *self,
                                  GtkAccessiblePlatformChange  change)
 {
-  GtkATContext *context = gtk_accessible_get_at_context (self);
+  GtkATContext *context;
+
+  if (GTK_IS_WIDGET (self) &&
+      gtk_widget_get_root (GTK_WIDGET (self)) == NULL)
+    return;
+
+  context = gtk_accessible_get_at_context (self);
 
   /* propagate changes up from ignored widgets */
   if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
     {
-      if (gtk_widget_get_parent (GTK_WIDGET (self)) == NULL)
-        return;
-
       context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (gtk_widget_get_parent (GTK_WIDGET (self))));
     }